The VBA INSTRREV Function returns an integer corresponding to the first position found of a value in a character string starting the search from the right.
The InStrRev function returns 0 if no match was found.
InStrRev(text, value)
Or
InStrRev(text, value, start_num, case)
Determine the position of the value XLP starting the search from the right of the text:
Sub InStrRevExample() text = "REF: XLP-54-21-XLP-9" 'First position of "XLP" in the text when searching from the right position = InStrRev(text, "XLP") MsgBox position 'Returns: 17 End Sub